<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>升班提醒页面</title>
<meta name="renderer" content="webkit">	
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">	
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">	
<meta name="apple-mobile-web-app-status-bar-style" content="black">	
<meta name="apple-mobile-web-app-capable" content="yes">	
<meta name="format-detection" content="telephone=no">
<link rel="stylesheet" href="css/reset.css">
<link rel="stylesheet" href="css/main.css">
<link rel="stylesheet" href="css/index.css">
<link rel="stylesheet" href="css/table.css">
</head>
<body>
	<div class="content-head">悦宝园会员管理系统</div>
	<div class="content-main">
		<div class="side-nav" ms-controller="navBar">
			<ul class="nav-item">
				<li><a href="main.html" class="nav-item-front nav-item-add">首页</a></li>
				<li ms-for="el in @navTitleArr">
					<a href="javascript:;" class="nav-item-front">{{el.par}}</a>
					<dl class="nav-item-child">
						<dd ms-for="($index, ex) in el.child"><a ms-attr='{href: el.href[$index]}'>{{ex}}</a></dd>
					</dl>
				</li>
			</ul>
		</div>
		<div class="content bg-gray" ms-controller="main">
			<div class="tab-content">
				<div class="tab-item">
					<div class="sub-main">
						<p class="sub-title"><i>升班提醒</i></p>
						<div class="table-area">
							<div class="table-head">
								<span class="col-15">宝宝姓名</span>
								<span class="col-15">出生日期</span>
								<span class="col-70">升班状态</span>
							</div>
							<div class="table-body">
								<div class="table-line" ms-for="el in @dataArr()">
									<div class="col-padding col-border col-inline col-center col-15">{{el.name}}</div>
									<div class="col-padding col-border col-inline col-center col-15">{{el.birthday}}</div>
									<div class="col-padding col-border col-inline col-center col-70" ms-html="upClassInfo(el.upClassInfo, el.flag)">
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
<script src="js/jq.js"></script>
<script src="js/avalon.js"></script>
<script src="js/main.js"></script>
<script>
(function() {
	var vm = avalon.define({
		$id: "main",
		dataArr: function() {
			var obj = baseFunc.getStorageData("member");
			if(obj) {
				var newObj = {};
				$.each(obj, function(index, el) {
					$.each(el.upClassInfo, function(index, bl) {
						if($.inArray("inConfirm", bl) != -1 || $.inArray("inTips", bl) != -1) {
							newObj[el.flag] = el;
						}
					})
				});
				return newObj;
			}
		},
		setText: function(strClass, upClassInfo, strName) {
			var tips = "";

			Object.getOwnPropertyNames(upClassInfo).forEach(function(key) {
				if(key.indexOf("$") == -1) {
					if(key == strName) {
						if(upClassInfo[key][2] == "inTips") {
							tips = "进入观察期";
						} else if(upClassInfo[key][2] == "inConfirm") {
							tips = "需要升班";
						}
					}
				}
			});
			return tips;
		},
		upClassInfo: function(info, flag) {
			var htm = "";
			Object.getOwnPropertyNames(info).forEach(function(key) {
				if(key.indexOf("$") == -1) {
					if(info[key][2] == "inTips") {
						htm += "<div><span class='color-tips color-block-green'>" + key + "进入观察期" + "</span><i class='color-check-tips' data-flag='"+flag+"' data-class='"+key+"'></i></div>";
					} else if(info[key][2] == "inConfirm") {
						htm += "<div><span class='color-tips color-block-red'>" + key + "需要升班" + "</span><i class='color-check-tips' data-flag='"+flag+"' data-class='"+key+"'></i></div>";
					}
				}
			});
			return htm;
		}
	});

	$("body").on("click", ".color-check-tips", function() {
		var elem = $(this),
			className = elem.attr("data-class"),
			flag = elem.attr("data-flag"),
			member = baseFunc.getStorageData("member", {flag: flag});

		for(var i in member[0].upClassInfo) {
			if(i == className) {
				member[0].upClassInfo[i][2] = "pass";
				baseFunc.editStorageData("member", member[0]);
				elem.parent().addClass("hide-elem");
				break;
			}
		}

	})
})();
</script>
</body>
</html>